package com.ruoyi.examination.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.examination.dto.ExamRecordDto;
import com.ruoyi.examination.dto.ExamRecordSpecialDto;
import com.ruoyi.examination.vo.ExamRecordSelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.examination.domain.ExamRecordSpecial;
import com.ruoyi.examination.service.IExamRecordSpecialService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 考试记录-特种设备Controller
 * 
 * @author hcc
 * @date 2025-11-03
 */
@RestController
@RequestMapping("/examRecordSpecial")
public class ExamRecordSpecialController extends BaseController
{
    @Autowired
    private IExamRecordSpecialService examRecordSpecialService;

    /**
     * 查询考试记录-特种设备列表
     */
    @RequiresPermissions("examination:examRecordSpecial:list")
    @GetMapping("/list")
    public TableDataInfo list(ExamRecordSpecial examRecordSpecial)
    {
        startPage();
        List<ExamRecordSpecial> list = examRecordSpecialService.selectExamRecordSpecialList(examRecordSpecial);
        return getDataTable(list);
    }

    /**
     * 导出考试记录-特种设备列表
     */
    @RequiresPermissions("examination:examRecordSpecial:export")
    @Log(title = "考试记录-特种设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamRecordSpecial examRecordSpecial)
    {
        List<ExamRecordSpecial> list = examRecordSpecialService.selectExamRecordSpecialList(examRecordSpecial);
        ExcelUtil<ExamRecordSpecial> util = new ExcelUtil<ExamRecordSpecial>(ExamRecordSpecial.class);
        util.exportExcel(response, list, "考试记录-特种设备数据");
    }

    /**
     * 获取考试记录-特种设备详细信息
     */
    @RequiresPermissions("examination:examRecordSpecial:query")
    @GetMapping(value = "/{examRecordId}")
    public AjaxResult getInfo(@PathVariable("examRecordId") String examRecordId)
    {
        return success(examRecordSpecialService.selectExamRecordSpecialByExamRecordId(examRecordId));
    }

    /**
     * 新增考试记录-特种设备
     */
    @RequiresPermissions("examination:examRecordSpecial:add")
    @Log(title = "考试记录-特种设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamRecordSpecial examRecordSpecial)
    {
        return toAjax(examRecordSpecialService.insertExamRecordSpecial(examRecordSpecial));
    }

    /**
     * 修改考试记录-特种设备
     */
    @RequiresPermissions("examination:examRecordSpecial:edit")
    @Log(title = "考试记录-特种设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamRecordSpecial examRecordSpecial)
    {
        return toAjax(examRecordSpecialService.updateExamRecordSpecial(examRecordSpecial));
    }

    /**
     * 删除考试记录-特种设备
     */
    @RequiresPermissions("examination:examRecordSpecial:remove")
    @Log(title = "考试记录-特种设备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examRecordIds}")
    public AjaxResult remove(@PathVariable String[] examRecordIds)
    {
        return toAjax(examRecordSpecialService.deleteExamRecordSpecialByExamRecordIds(examRecordIds));
    }

    /**
     * 查询考试记录列表
     */
    @RequiresPermissions("examination:examRecordSpecial:list")
    @GetMapping("/getExamSpecialList")
    public TableDataInfo getExamSpecialList(ExamRecordSelectVo examRecordSelectVo)
    {
        startPage();
        List<ExamRecordSpecialDto> list = examRecordSpecialService.getExamSpecialList(examRecordSelectVo);
        return getDataTable(list);
    }
}
